package com.zfj.Generic;

import com.zfj.Collection.Student;

import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.Iterator;

/**
 * @author zfj
 * @date 2022/3/5 -22:01
 */
public class Demo2 {
	public static void main(String[] args) {
		ArrayList<String> arrayList=new ArrayList<>();
		arrayList.add("xxxxx");
		arrayList.add("yyy");
//		arrayList.add(120);
//		arrayList.add(1550);
		for (String s:arrayList){
			System.out.println(s);
		}
		ArrayList<Student> a=new ArrayList<>();
		//添加学生对象
		Student s1=new Student("张三",20);
		Student s2=new Student("李四",22);
		Student s3=new Student("王五",25);
		a.add(s1);
		a.add(s2);
		a.add(s3);
		Iterator<Student> it=a.iterator();
		while(it.hasNext()){
			Student s=it.next();
			System.out.println(s.toString());
		}
	}
}
